//
//  ClassificationListTableViewCell.m
//  BakeCenter
//
//  Created by 杨洋 on 15/9/21.
//  Copyright (c) 2015年 Baked. All rights reserved.
//

#import "ClassificationListTableViewCell.h"

@implementation ClassificationListTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.listImage = [[UIImageView alloc] init];
        [self.contentView addSubview:self.listImage];
        
        [self.listImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).offset(10);
            make.top.equalTo(self.mas_top).offset(10);
            make.bottom.equalTo(self.mas_bottom).offset(-5);
            make.right.equalTo(self.mas_right).offset(-kScreenWidth / 1.6);
        }];
        
        UIImageView *lineImage = [[UIImageView alloc] init];
        lineImage.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:lineImage];
        
        [lineImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).offset(10);
            make.right.equalTo(self.mas_right).offset(-10);
            make.top.equalTo(self.listImage.mas_bottom).offset(3);
            make.height.mas_equalTo(@1);
        }];
        
        self.nameLabel = [[UILabel alloc] init];
        self.nameLabel.font = [UIFont boldSystemFontOfSize:16];
        [self.nameLabel sizeToFit];
        [self.contentView addSubview:self.nameLabel];
        
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.listImage.mas_right).offset(5);
            make.top.equalTo(self.listImage.mas_top).offset(5);
            make.height.mas_equalTo(@25);
            //make.right.equalTo(self.mas_right).offset(- 100);
        }];
        
        self.stepLabel = [[UILabel alloc] init];
        self.stepLabel.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1];
        self.stepLabel.text = @"步骤图";
        self.stepLabel.font = [UIFont systemFontOfSize:10];
        self.stepLabel.textAlignment = NSTextAlignmentCenter;
        self.stepLabel.layer.cornerRadius = 3;
        self.stepLabel.layer.masksToBounds = YES;
        self.stepLabel.textColor = [UIColor colorWithWhite:0.5 alpha:1];
        [self.contentView addSubview:self.stepLabel];
        
        [self.stepLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.nameLabel.mas_right).offset(3);
            make.top.equalTo(self.nameLabel.mas_top).offset(5);
            make.height.mas_equalTo(@15);
            make.width.mas_equalTo(@35);
        }];
        
        self.detailsLabel = [[UILabel alloc] init];
        self.detailsLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.detailsLabel];
        
        [self.detailsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.nameLabel.mas_bottom).offset(15);
            make.left.equalTo(self.nameLabel);
            make.right.equalTo(self.mas_right).offset(-10);
            make.height.mas_equalTo(@20);
        }];
        
        self.browseLabel = [[UILabel alloc] init];
        self.browseLabel.textColor = [UIColor grayColor];
        self.browseLabel.font = [UIFont systemFontOfSize:12];
        [self.browseLabel sizeToFit];
        [self.contentView addSubview:self.browseLabel];
        
        [self.browseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.detailsLabel);
            make.top.equalTo(self.detailsLabel.mas_bottom).offset(8);
            make.bottom.equalTo(self.listImage.mas_bottom).offset(-5);
        }];
        
        self.collectLabel = [[UILabel alloc] init];
        self.collectLabel.textColor = [UIColor grayColor];
        self.collectLabel.font = [UIFont systemFontOfSize:12];
        [self.collectLabel sizeToFit];
        [self.contentView addSubview:self.collectLabel];
        
        [self.collectLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.browseLabel.mas_right).offset(30);
            make.top.equalTo(self.browseLabel.mas_top).offset(0);
            make.height.equalTo(self.browseLabel);
        }];
    }
    return self;
}

#pragma mark ----- model传值方法 -----
- (void)shareCellWithModel:(ClassificationListModel *)model
{
    [self.listImage sd_setImageWithURL:[NSURL URLWithString:model.coverImage]];
    self.nameLabel.text = model.coverTitle;
    self.detailsLabel.text = model.coverSummary;
    self.browseLabel.text = [NSString stringWithFormat:@"%@收藏", model.collectNum];
    self.collectLabel.text = model.clientName;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
